package Model;

/**
 * 
 * @author mada
 * classe contact implementé de Comparable pour
 * permettre de trier les contactes par ordre
 * alphabétique
 */

public class Contact implements Comparable{
	private String lastName;//nom
	private String firstName;//prenom
	private String hmAdd;
	private String cmpAdd;
	private String phone;
	private String profPhone;
	private String mail;
	private String groupe;
	
	
	
	public Contact(){
	}
	
	public Contact(String lN, String fN,String hA,String cA, String p, String pP, String m, String g){
		
		this.lastName=lN;
		this.firstName=fN;
		this.hmAdd=hA;
		this.cmpAdd=cA;
		this.phone=p;
		this.profPhone=pP;
		this.mail=m;
		this.groupe=g;
		//this.id=id;
		
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getHmAdd() {
		return hmAdd;
	}

	public void setHmAdd(String hmAdd) {
		this.hmAdd = hmAdd;
	}

	public String getCmpAdd() {
		return cmpAdd;
	}

	public void setCmpAdd(String cmpAdd) {
		this.cmpAdd = cmpAdd;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getProfPhone() {
		return profPhone;
	}

	public void setProfPhone(String profPhone) {
		this.profPhone = profPhone;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getGroupe() {
		return groupe;
	}

	public void setGroupe(String groupe) {
		this.groupe = groupe;
	}


	
	public String toString(){
		return this.getLastName() + ","+
				 this.getFirstName() + ","+
				 this.getHmAdd() + ","+
				 this.getCmpAdd() + ","+
				 this.getPhone() + ","+
				 this.getProfPhone() + ","+
				this.getMail() + ","+
				 this.getGroupe()+"\n";
		}
/**
 * Trie les contactes par ordre alphabétique
 */
	@Override
	public int compareTo(Object o) {
		Contact c=(Contact)o;
		if(lastName.equals(c.lastName)){
			return firstName.compareTo(c.lastName);
		}
		return lastName.compareTo(c.lastName);
	}	
}
